<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <title>报表规则</title>
</head>
<body>
<div class="pageheader">
    <h2>报表规则</h2>
</div>
<div class="contentpanel">
    <div class="form-inline">
        <div class="btn-group mr10">
            <a href="edit.htm" class="btn btn-primary"
               type="button">
                <i class="fa fa-pencil mr5"></i>添加规则
            </a>
        </div>
    </div>
    <table class="table table-striped dataTable no-footer" id="table2" role="grid" aria-describedby="table2_info">
        <thead>
        <tr role="row">
            <th class="sorting_asc" tabindex="0" aria-controls="table2" rowspan="1" colspan="1" aria-sort="ascending">
                规则名称
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2" rowspan="1" colspan="1" aria-sort="ascending">
                sql
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2" rowspan="1" colspan="1" aria-sort="ascending">
                内容
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2" rowspan="1" colspan="1" aria-sort="ascending">
                部门
            </th>
            <th class="sorting" tabindex="0" aria-controls="table2" rowspan="1" colspan="1">
                操作
            </th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${listDto.list}" var="item" varStatus="status">
            <tr class="gradeA ${status.index/2 eq 0?"odd":"even"}">
                <td>
                        ${item.name}
                </td>
                <td>
                    <button type="button" class="btn btn-info btn-xs" data-container="body" data-toggle="popover"
                            data-placement="right"
                            data-content="${item.sql}">
                        <span class="fa fa-info-circle"></span>
                    </button>
                </td>
                <td>
                    <button type="button" class="btn btn-info ShowContent" url="content.htm?uuid=${item.uuid}"
                            data-toggle="modal"
                            data-target="#myModal">
                        查看内容
                    </button>
                </td>
                <td>
                    <span>${item.deptDto.name}</span>
                </td>
                <td>
                    <form class="form-inline" action="delete.htm" method="post">
                        <input type="hidden" name="uuid" value="${item.uuid}"/>
                        <a class="btn btn-primary" href="edit.htm?uuid=${item.uuid}">编辑</a>
                        <a class="btn btn-primary" href="preview.htm?uuid=${item.uuid}">预览</a>
                        <button type="submit" class="btn btn-danger" onclick="return confirm('确定删除当前的规则吗}]?');">
                            删除
                        </button>
                    </form>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <custom:page page="${listDto}"/>

    <script type="text/javascript">
        <c:if test="${not empty param.edit}">
        jQuery.gritter.add({
            title: '添加/修改成功!',
            class_name: "growl-success",
            sticky: false
        });
        </c:if>
        <c:if test="${not empty param.delete}">
        jQuery.gritter.add({
            title: '删除成功!',
            class_name: "growl-primary",
            sticky: false
        });
        </c:if>
    </script>

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>

    <script src="${contextPath}/resources/js/jquery.datatables.min.js"></script>
    <script type="text/javascript">
        $(function () {
            jQuery('#table2').dataTable({
                "bPaginate": false,// 分页按钮
                "bFilter": false,// 搜索栏
                "bLengthChange": false,// 每行显示记录数
                "bInfo": false
            });
            $('[data-toggle="popover"]').popover({html: true});
        });

        $(".ShowContent").click(function () {
            var url = $(this).attr("url");
            $(".modal-content").load(url);
        });

        $("body").on("click", ".loadModal", function () {
            var url = $(this).attr("url");
            $(".modal-content").load(url);
        });
    </script>
</div>
</body>
</html>
